package cl.rizepe.playntest.core.effects;

import static playn.core.PlayN.graphics;
import playn.core.Image;
import playn.core.ImageLayer;
import playn.core.Layer;

public class EffectFactory {
	public static ImageLayer createShadow(Layer layer, Image image, float alphaFactor, float scale){
		ImageLayer layerShadow=graphics().createImageLayer(image);
		if (layer.parent()!=null)
			layer.parent().add(layerShadow);
		duplicateLayerAttributes(layer,layerShadow);
	    layerShadow.setAlpha(layer.alpha()*alphaFactor);
	    layerShadow.setVisible(true);
	    layerShadow.setScale(scale);
	    return layerShadow;
	}

	public static ImageLayer duplicateImageLayerAttributes(ImageLayer source, ImageLayer destiny){
		duplicateLayerAttributes(source,destiny);
		destiny.setScale(source.transform().uniformScale());
		return destiny;
	}
	
	public static Layer duplicateLayerAttributes(Layer source, Layer destiny){
		pythagoras.f.Transform transform=source.transform();
		destiny.setOrigin(source.originX(),source.originY());
		destiny.setTranslation(transform.tx(),transform.ty());
		destiny.setRotation(transform.rotation());
		destiny.setScale(transform.scaleX(),transform.scaleY());
		return destiny;
	}
	
	public EffectFactory() {
		// TODO Auto-generated constructor stub
	}

}
